<template>
	<view>
		<!-- 这里的每一个Card就是一个工厂，选择之后再进行跳转 -->
		<u-empty v-if="!factoryList || factoryList.length < 1" text="暂无数据" mode="list"></u-empty>
		<u-card
			v-if="factoryList.length > 0"
			v-for="(item,index) in factoryList"
			:title="item.name"
			:sub-title="item.location"
		>
			<view class="" slot="body">
				<view class="u-flex u-col-between u-p-t-0">
					<image style="height: 128px;" :src="`https://zhuchang.people.phper.wiki${item.image}`" mode="scaleToFill"></image>
				</view>
			</view>
			<view class="" slot="foot">
				<u-row justify="end">
					<u-button
						type="primary"
						size="default"
						@click="toNextUri(item)"
					>
						选择工厂
					</u-button>	
				</u-row>
			</view>
		</u-card>
	</view>
</template>

<script>
	import { getAllFactory } from '../../util/request.js'
	export default {
		props: {
			nextBaseUri: {
				type: String,
				default: ''
			}
		},
		onLoad(options) {
			this.nextBaseUri = options.nextUri
		},
		data() {
			return {
				factoryList: [],
				searchParams: {
					
				}
			};
		},
		created() {
			getAllFactory().then(res => {
				this.factoryList = res.data.data
			})
		},
		methods: {
			toNextUri(item) {
				const _nextBaseUri = `${this.nextBaseUri}?factory_id=${item.id}`
				uni.navigateTo({
					url: _nextBaseUri
				})
			}
		}
	}
</script>

<style lang="less">

</style>
